package com.yulongtian.oneProblemEveryDay.month202211.day20221119;

/**
 * @author yulongTian
 * @create 2022-11-19 12:54
 */
public class Test01 {
    public static void main(String[] args) {
        int[] gain={-4,-3,-2,-1,4,3,2};
        System.out.println(largestAltitude(gain));
    }

    public static int largestAltitude(int[] gain) {
        int res=0;
        int[] temp=new int[gain.length+1];
        for (int i = 1; i < gain.length+1; i++) {
            temp[i]=temp[i-1]+gain[i-1];
            res=Math.max(temp[i],res);
        }
        return res;
    }

}
